package com.yic.module.wms.dal.mysql.itemwarehouse;

import java.util.*;

import com.yic.framework.common.pojo.PageResult;
import com.yic.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yic.framework.mybatis.core.mapper.BaseMapperX;
import com.yic.module.wms.dal.dataobject.itemwarehouse.ItemWarehouseDO;
import org.apache.ibatis.annotations.Mapper;
import com.yic.module.wms.controller.admin.itemwarehouse.vo.*;

/**
 * 产品仓储信息 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface ItemWarehouseMapper extends BaseMapperX<ItemWarehouseDO> {

    default PageResult<ItemWarehouseDO> selectPage(ItemWarehousePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ItemWarehouseDO>()
                .eqIfPresent(ItemWarehouseDO::getFactoryId, reqVO.getFactoryId())
                .eqIfPresent(ItemWarehouseDO::getItemId, reqVO.getItemId())
                .eqIfPresent(ItemWarehouseDO::getItemType, reqVO.getItemType())
                .eqIfPresent(ItemWarehouseDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(ItemWarehouseDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ItemWarehouseDO::getId));
    }

    default List<ItemWarehouseDO> selectList(ItemWarehouseExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ItemWarehouseDO>()
                .eqIfPresent(ItemWarehouseDO::getFactoryId, reqVO.getFactoryId())
                .eqIfPresent(ItemWarehouseDO::getItemId, reqVO.getItemId())
                .eqIfPresent(ItemWarehouseDO::getItemType, reqVO.getItemType())
                .eqIfPresent(ItemWarehouseDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(ItemWarehouseDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ItemWarehouseDO::getId));
    }

    default ItemWarehouseDO selectByFactoryAndItem(Long factoryId, Long itemId) {
        return selectOne(new LambdaQueryWrapperX<ItemWarehouseDO>()
                .eq(ItemWarehouseDO::getFactoryId, factoryId)
                .eq(ItemWarehouseDO::getItemId, itemId));

    }
}
